/********************************************************************
 * Copyright(c) 2023-2023 Grayson Zheng.
 * File: uart.C
 * Description: Header file for HC-SR04 ultrasonic ranging module
 * driver.
 * Version: 1.0
 * Date: 2023-07-21
 * Author: zhengxinyu13@qq.com
 * ---------- Revision History ----------
 * <version>
 * <date>
 * <author>
 * <desc>
 * Modified to be suitable to the new coding rules in all functions.
 ********************************************************************/

#include "regx52.h"
#include "STC89C5xRC-rdp.h"
#include "datatype.h"
#include "bit.h"
#include "delay.h"

#ifndef __HC_SR04_H__
#define __HC_SR04_H__

#define SPEED_SOUND	0.034	//Speed of sound (cm/us)
#define HALF		0.5

#define RESET(a) 				(a = 0x00)
#define SHIFT_8_BITS_LEFT(a)	(a * 256)

#define MACHINE_CYCLE  (fp_64)(12000000.00/11059200.00)

sbit TRIG  = P3^5;
sbit ECHO  = P3^4;

void time0_init(void);
void start_ultrasonic(void);
fp_64 get_distance(void);
void distance_string(uint_8 *string, uint_16 len);

#endif